package com.knight.study.patterns.tujie.abstractFactory;

/**
 * @Author knight
 * @Date 2024/9/10 18:58
 */

public class abstractFactoryMains {
    public static void main(String[] args) {
        if (args.length != 1) {
            System.out.println("Usage: java Main class.name.of.ConcreteFactory");
            System.out.println("Example 1:java Main listfactory.ListFactory");
            System.out.println("Example 2:java Main tablefactory.TableFactory");
            System.exit(0);
        }
        final Factory factory = Factory.getFactory(args[0]);

        Link people = factory.createLink("人民日报", "人民日报-url");
        Link gmw = factory.createLink("光明日报", "光明日报-url");
        Link us_yahoo = factory.createLink("us_yahoo", "us_yahoo-url");
        Link jp_yaho = factory.createLink("jp_yaho", "jp_yaho-url");
        Link excite = factory.createLink("excite", "excite-url");
        Link google = factory.createLink("google", "google-url");

        Tray traynews = factory.createTray("日报");
        traynews.add(people);
        traynews.add(gmw);

        Tray trayyahoo = factory.createTray("Yahoo!");
        trayyahoo.add(us_yahoo);
        trayyahoo.add(jp_yaho);

        Tray traysearch = factory.createTray("检索引擎");
        traysearch.add(trayyahoo);
        traysearch.add(excite);
        traysearch.add(google);

        Page page = factory.createPage("LinkPage", "郭志斌");
        page.add(traynews);
        page.add(traysearch);
        page.output();
    }
}
